home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.Image;
-
- public class JackhammerDuke extends Applet implements Runnable {
- int seqslot;
- int nimgs = 4;
- Image imgs;
- String dir;
- Thread kicker;
- int pause;
- // $FF: renamed from: x double
- double field_0;
- int imgsWidth = 328;
- int imgsHeight = 90;
- private int[] sequence = new int[]{2, 1, 0, 1, 0, 1, 0, 1, 2, 1, 0, 2, 0, 1, 0, 2, 3};
- boolean erase;
-
- public void run() {
- Thread.currentThread().setPriority(1);
- this.imgs = ((Applet)this).getImage(((Applet)this).getCodeBase(), "images/jack.gif");
- if (this.imgs != null) {
- int var10002 = this.imgsWidth / this.nimgs;
-
- for(this.field_0 = (double)((((Component)this).size().width - var10002) / 2); ((Component)this).size().width > 0 && ((Component)this).size().height > 0 && this.kicker != null; this.seqslot = (this.seqslot + 1) % this.sequence.length) {
- if (this.seqslot == 0) {
- ((Applet)this).play(((Applet)this).getCodeBase(), "audio/jackhammer-short.au");
- }
-
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)(this.seqslot == this.sequence.length - 1 ? 500 : 100));
- } catch (InterruptedException var1) {
- }
- }
- }
-
- }
-
- public void update(Graphics g) {
- if (this.erase || this.sequence[this.seqslot] == 3) {
- g.setColor(Color.lightGray);
- g.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- this.erase = false;
- }
-
- this.paint(g);
- }
-
- public void paint(Graphics g) {
- int loopslot = this.sequence[this.seqslot];
- if (this.imgs != null && loopslot < this.nimgs) {
- int w = this.imgsWidth / this.nimgs;
- this.field_0 = Math.max((double)0.0F, Math.min((double)(((Component)this).size().width - w), this.field_0 + Math.random() * (double)4.0F - (double)2.0F));
- g.clipRect((int)this.field_0, 0, w, this.imgsHeight);
- g.drawImage(this.imgs, (int)this.field_0 - loopslot * w, 0, this);
- this.erase = loopslot == 3;
- }
-
- }
-
- public void start() {
- if (this.kicker == null) {
- this.kicker = new Thread(this);
- this.kicker.start();
- }
-
- }
-
- public void stop() {
- this.kicker = null;
- }
- }
-